home *** CD-ROM | disk | FTP | other *** search
- {*******************************************************
- GrepLoad Unit
-
- This unit explicitly loads REGEXP.DLL (shipped with BP 7.01).
-
-
- Paul Warren
- HomeGrown Software Development
- (c) 1995 Langley British Columbia.
- (604) 530-9097
- e-mail: hg_soft@uniserve.com
- Home page: http://haven.uniserve.com/~hg_soft
-
- ********************************************************}
-
- unit GrepLoad;
-
- interface
-
- const
- GrepLoaded: Boolean = False; { presume nothing! }
-
- type
- HRegexp = Word;
-
- TRegMatch = record
- Start: Word; { Start of match }
- Stop: Word; { End of match }
- end;
-
- var
- RegComp: function(Pattern: PChar; var Error: Integer): HRegexp;
- RegExec: function(Regex: HRegexp; Str: PChar; var Match: TRegMatch): Integer;
- RegError: function(Regex: HRegexp; Error: Integer; ErrorBuf: array of Char): Integer;
- RegFree: procedure(Regex: HRegexp);
-
- implementation
- {$IFDEF WINDOWS}
- uses WinProcs;
- Const SEM_NoOpenFileErrorBox = $8000;
- {$ELSE}
- uses WinAPI;
- {$ENDIF}
-
- var
- SaveExit: pointer;
- DLLHandle: Word;
-
- procedure NewExit; far;
- begin
- ExitProc := SaveExit;
- FreeLibrary(DLLHandle)
- end {NewExit};
-
- begin
- {$IFDEF WINDOWS}
- SetErrorMode(SEM_NoOpenFileErrorBox);
- {$ENDIF}
- DLLHandle := LoadLibrary('REGEXP.DLL');
- if DLLHandle >= 32 then
- begin
- GrepLoaded := True;
- SaveExit := ExitProc;
- ExitProc := @NewExit;
- @RegComp := GetProcAddress(DLLHandle,'REGCOMP');
- @RegExec := GetProcAddress(DLLHandle,'REGEXEC');
- @RegError := GetProcAddress(DLLHandle,'REGERROR');
- @RegFree := GetProcAddress(DLLHandle,'REGFREE');
- end
- end.
-